/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 将按钮固定到单词卡片左右外侧（以卡片容器为定位参照） */
.card-container {
    position: relative; /* 作为定位参照 */
}

#prevBtn,
#nextBtn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    transition: all 0.3s ease;
}

#prevBtn:hover,
#nextBtn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 12px 28px rgba(0,0,0,0.25);
}

/* 定位到卡片容器左右外侧 */
#prevBtn { left: -70px; }
#nextBtn { right: -70px; }

/* 仅保留图标的居中显示 */
#prevBtn i, #nextBtn i { margin: 0; }

/* 移动端回退：按钮回到原有控制区内，避免遮挡卡片内容 */
@media (max-width: 768px) {
    #prevBtn,
    #nextBtn {
        position: static;
        transform: none;
        width: auto;
        height: auto;
        padding: 12px 18px;
        border-radius: 24px;
        box-shadow: none;
        font-size: 14px;
        background: linear-gradient(135deg, #667eea, #764ba2);
    }
    
    #prevBtn:hover,
    #nextBtn:hover {
        transform: translateY(-2px);
    }
}

/* 浮动导航按钮（桌面端悬浮在卡片左右居中） */
.card-container {
    position: relative;
}

#prevBtn,
#nextBtn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

/* 左右具体位置（可根据视觉微调） */
#prevBtn { left: -18px; }
#nextBtn { right: -18px; }

/* 若按钮含文字，移除多余外边距以居中图标 */
#prevBtn i, #nextBtn i { margin: 0; }

/* 保证控制条宽度，避免与悬浮按钮冲突 */
.nav-controls { max-width: 600px; }

/* 移动端（<=768px）：回到流式布局，避免遮挡卡片内容 */
@media (max-width: 768px) {
    #prevBtn,
    #nextBtn {
        position: static;
        transform: none;
        width: auto;
        height: auto;
        padding: 12px 18px;
        border-radius: 24px;
        box-shadow: none;
        font-size: 14px;
    }
    .nav-controls {
        justify-content: center;
        gap: 12px;
        max-width: 100%;
    }
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.app-title {
    color: white;
    font-size: 2.2em;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.app-title i {
    margin-right: 10px;
    color: #ffd700;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.mode-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
/* 新增：模式下拉样式（用于替代三个模式按钮时） */
.mode-label {
    color: #fff;
    opacity: 0.95;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95em;
}
.mode-select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    padding: 10px 36px 10px 12px;
    font-size: 0.95em;
    color: #fff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    backdrop-filter: blur(6px);
}
.mode-select option {
    color: #333;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border-color: white;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

/* 单词卡片样式 */
.card-container {
    perspective: 1000px;
    width: 100%;
    max-width: 500px;
}

.word-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.word-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.word-card.clicked {
    animation: cardFlip 0.6s ease-in-out;
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

.chinese-word {
    font-size: 3.5em;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.word-info {
    transition: all 0.5s ease;
    opacity: 0;
    transform: translateY(20px);
}

.word-info:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

.pinyin {
    font-size: 1.8em;
    color: #e74c3c;
    font-weight: 500;
    margin-bottom: 15px;
    font-style: italic;
}

.meaning {
    font-size: 1.2em;
    color: #7f8c8d;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

.audio-btn, .favorite-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

.audio-btn {
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.audio-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.favorite-btn {
    top: 20px;
    left: 20px;
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.favorite-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(149, 165, 166, 0.4);
}

.favorite-btn.favorited {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.favorite-btn.favorited i {
    color: #fff;
}

/* 控制按钮 */
.controls {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 15px 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-wrap: wrap;
    justify-content: center;
}
/* 新增：导航左右分布容器 */
.nav-controls {
    justify-content: space-between;
    width: 100%;
    max-width: 560px;
}
.nav-controls .progress-info {
    order: 2;
}
.nav-controls #prevBtn {
    order: 1;
}
.nav-controls #nextBtn, .nav-controls #jumpBtn {
    order: 3;
}

.control-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.progress-info {
    color: white;
    font-size: 1.2em;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 统计信息 */
.stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 15px 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.stat-item i {
    font-size: 1.2em;
    color: #ffd700;
}

/* 提示信息 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #2ecc71;
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transform: translateX(400px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: #e74c3c;
}

/* 设置面板样式 */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.settings-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.settings-overlay:not(.hidden) .settings-panel {
    transform: scale(1);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 20px 20px 0 0;
}

.settings-header h3 {
    margin: 0;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.settings-content {
    padding: 25px;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.voice-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.radio-option:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 50%;
    position: relative;
    transition: all 0.3s ease;
}

.radio-option input[type="radio"]:checked + .radio-custom {
    border-color: #667eea;
    background: #667eea;
}

.radio-option input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.option-info strong {
    display: block;
    color: #333;
    margin-bottom: 4px;
}

.option-info small {
    color: #666;
    font-size: 0.9em;
}

.parameter-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.parameter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.parameter-item label {
    font-weight: 500;
    color: #555;
    min-width: 60px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    margin-left: 20px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.9em;
}

.voice-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.voice-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.config-info {
    background: rgba(102, 126, 234, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    padding: 15px;
}

.config-info p {
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
    font-size: 0.9em;
}

.config-info i {
    color: #667eea;
}

.test-voice-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 auto;
}

.test-voice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.4);
}

.settings-footer {
    padding: 20px 25px;
    border-top: 1px solid #eee;
    text-align: center;
}

.save-settings-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
}

.save-settings-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .app-container {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
    }
    
    .app-title {
        font-size: 1.8em;
    }
    
    .mode-selector {
        gap: 8px;
    }
    
    .mode-btn {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .word-card {
        padding: 30px 20px;
        min-height: 250px;
    }
    
    .chinese-word {
        font-size: 2.8em;
    }
    
    .pinyin {
        font-size: 1.5em;
    }
    
    .meaning {
        font-size: 1.1em;
    }
    
    .controls {
        gap: 20px;
        padding: 12px 20px;
    }
    
    .control-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .stats {
        gap: 15px;
    }
    
    .stat-item {
        padding: 12px 15px;
        font-size: 14px;
    }
}

/* 跳转面板样式 */
.jump-panel {
    max-width: 400px;
}

.jump-input-group {
    margin-top: 10px;
}

.jump-input-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 18px;
    text-align: center;
    transition: all 0.3s ease;
}

.jump-input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

@media (max-width: 480px) {
    .chinese-word {
        font-size: 2.2em;
    }
    
    .controls {
        flex-direction: column;
        gap: 15px;
    }
    /* 移动端下，左右分布容器退回为垂直堆叠，避免挤压 */
    .nav-controls {
        max-width: 100%;
        justify-content: center;
    }
    .nav-controls .progress-info,
    .nav-controls #prevBtn,
    .nav-controls #nextBtn,
    .nav-controls #jumpBtn {
        order: initial;
    }
    
    .stats {
        flex-direction: column;
        align-items: center;
    }
}